package com.kaochong.xcx.utils.response;


import com.kaochong.xcx.enums.ResultEnum;

import lombok.Data;

/**
 * Response工具类
 * @author han
 * @date 2018-05-01 14:43
 */
@Data
public class ResponseUtils {

    public static ResultVO success(){
        ResultVO result = new ResultVO();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setErrMsg(ResultEnum.SUCCESS.getMessage());
        return result;
    }

    public static ResultVO success(Object object){
        ResultVO result = new ResultVO();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setErrMsg(ResultEnum.SUCCESS.getMessage());
        result.setData(object);
        return result;
    }

    public static ResultVO error(ResultEnum error){
        ResultVO result = new ResultVO();
        result.setCode(error.getCode());
        result.setErrMsg(error.getMessage());
        return result;
    }
    
    public static ResultVO error(Integer code, String message) {
        ResultVO result = new ResultVO();
        result.setCode(code);
        result.setErrMsg(message);
        return result;
    }
    
    public static ResultVO error(ResultEnum error, String data) {
        ResultVO result = new ResultVO();
        result.setCode(error.getCode());
        result.setErrMsg(error.getMessage());
        result.setData(data);
        return result;
    }
}
